package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (产品分类属性项)TB_ProductCategoryPropertyItem
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ProductCategoryPropertyItem#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_productCategoryPropertyItem")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("产品分类属性项")
@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类属性项")
public class TB_ProductCategoryPropertyItem
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 产品分类属性 */
		public bairui.international.model.domain.jpa.TB_ProductCategoryProperty getProductCategoryProperty();
		/** 产品属性项 */
		public bairui.international.model.domain.jpa.TB_ProductPropertyItem getProductPropertyItem();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ProductCategoryPropertyItem properties(MustProperties properties) {
		this.setProductCategoryProperty(properties.getProductCategoryProperty());
		this.setProductPropertyItem(properties.getProductPropertyItem());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ProductCategoryPropertyItem(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ProductCategoryPropertyItem properties(OptionalSingleProperties properties) {
		return this;
	}
	
	
	
	public TB_ProductCategoryPropertyItem(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 产品分类属性 */
		public bairui.international.model.domain.jpa.TB_ProductCategoryProperty getProductCategoryProperty();
		/** 产品属性项 */
		public bairui.international.model.domain.jpa.TB_ProductPropertyItem getProductPropertyItem();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_ProductCategoryPropertyItem properties(CurrentMustProperties properties) {
		this.setProductCategoryProperty(properties.getProductCategoryProperty());
		this.setProductPropertyItem(properties.getProductPropertyItem());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_ProductCategoryPropertyItem properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_ProductCategoryPropertyItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_ProductCategoryPropertyItem(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_ProductCategoryPropertyItem update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_ProductCategoryPropertyItem.this);
			if(isOverride_getOrderValue){
				TB_ProductCategoryPropertyItem.this.setOrderValue(orderValue);
			}
	
			bairui.international.model.domain.jpa.TB_ProductCategoryProperty productCategoryProperty = getProductCategoryProperty(TB_ProductCategoryPropertyItem.this);
			if(isOverride_getProductCategoryProperty){
				TB_ProductCategoryPropertyItem.this.setProductCategoryProperty(productCategoryProperty);
			}
	
			bairui.international.model.domain.jpa.TB_ProductPropertyItem productPropertyItem = getProductPropertyItem(TB_ProductCategoryPropertyItem.this);
			if(isOverride_getProductPropertyItem){
				TB_ProductCategoryPropertyItem.this.setProductPropertyItem(productPropertyItem);
			}
		}
	
		public TB_ProductCategoryPropertyItem up(){
			return TB_ProductCategoryPropertyItem.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_ProductCategoryPropertyItem it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 产品分类属性 */
		private boolean isOverride_getProductCategoryProperty = true;
		public bairui.international.model.domain.jpa.TB_ProductCategoryProperty getProductCategoryProperty(TB_ProductCategoryPropertyItem it) throws Exception { 
			isOverride_getProductCategoryProperty = false; 
			return null;
		}
		/** 产品属性项 */
		private boolean isOverride_getProductPropertyItem = true;
		public bairui.international.model.domain.jpa.TB_ProductPropertyItem getProductPropertyItem(TB_ProductCategoryPropertyItem it) throws Exception { 
			isOverride_getProductPropertyItem = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ProductCategoryPropertyItem() {
	}
	
	public TB_ProductCategoryPropertyItem(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_ProductCategoryPropertyItem(
		@lombok.NonNull TB_ProductCategoryPropertyItem bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setProductCategoryProperty(bean.getProductCategoryProperty());
		this.setProductPropertyItem(bean.getProductPropertyItem());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("产品分类属性")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品分类属性")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_ProductCategoryProperty productCategoryProperty;

	@com.lianjing.sh.model.common.annotation.Comment("产品属性项")
	@com.lianjing.sh.processing.info.annotation.InfoComment("产品属性项")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_ProductPropertyItem productPropertyItem;

	@com.lianjing.sh.model.common.annotation.Comment("创建者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("创建者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="creator_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin creator;

	@com.lianjing.sh.model.common.annotation.Comment("最后修改者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("最后修改者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.JoinColumn(name="lastModifier_id", nullable=false)
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_Admin lastModifier;

	/** get[产品分类属性] */
	public bairui.international.model.domain.jpa.TB_ProductCategoryProperty getProductCategoryProperty() {
		return this.productCategoryProperty;
	}

	/** get[产品属性项] */
	public bairui.international.model.domain.jpa.TB_ProductPropertyItem getProductPropertyItem() {
		return this.productPropertyItem;
	}

	/** get[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin getCreator() {
		return this.creator;
	}

	/** get[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin getLastModifier() {
		return this.lastModifier;
	}

	/** set[产品分类属性] */
	public void setProductCategoryProperty(bairui.international.model.domain.jpa.TB_ProductCategoryProperty productCategoryProperty) {
		this.productCategoryProperty = productCategoryProperty;
	}

	/** set[产品属性项] */
	public void setProductPropertyItem(bairui.international.model.domain.jpa.TB_ProductPropertyItem productPropertyItem) {
		this.productPropertyItem = productPropertyItem;
	}

	/** set[创建者] */
	public void setCreator(bairui.international.model.domain.jpa.TB_Admin creator) {
		this.creator = creator;
	}

	/** set[最后修改者] */
	public void setLastModifier(bairui.international.model.domain.jpa.TB_Admin lastModifier) {
		this.lastModifier = lastModifier;
	}

	public void assignProductCategoryProperty(bairui.international.model.domain.jpa.TB_ProductCategoryProperty productCategoryProperty) {
		if(null != productCategoryProperty){
			productCategoryProperty.addProductCategoryPropertyItems(this);
		}
		this.setProductCategoryProperty(productCategoryProperty);
	}
	

	public void assignProductPropertyItem(bairui.international.model.domain.jpa.TB_ProductPropertyItem productPropertyItem) {
		if(null != productPropertyItem){
			productPropertyItem.addProductCategoryPropertyItems(this);
		}
		this.setProductPropertyItem(productPropertyItem);
	}
	



	
	
	

	/** take[产品分类属性] */
	public bairui.international.model.domain.jpa.TB_ProductCategoryProperty takeProductCategoryProperty(){
		if(null == this.productCategoryProperty){
			this.productCategoryProperty = new bairui.international.model.domain.jpa.TB_ProductCategoryProperty();
		}
		return this.productCategoryProperty;
	}
	
	/** take[产品属性项] */
	public bairui.international.model.domain.jpa.TB_ProductPropertyItem takeProductPropertyItem(){
		if(null == this.productPropertyItem){
			this.productPropertyItem = new bairui.international.model.domain.jpa.TB_ProductPropertyItem();
		}
		return this.productPropertyItem;
	}
	
	/** take[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin takeCreator(){
		if(null == this.creator){
			this.creator = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.creator;
	}
	
	/** take[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin takeLastModifier(){
		if(null == this.lastModifier){
			this.lastModifier = new bairui.international.model.domain.jpa.TB_Admin();
		}
		return this.lastModifier;
	}
	
	/** must[产品分类属性] */
	public bairui.international.model.domain.jpa.TB_ProductCategoryProperty mustProductCategoryProperty() {
		return this.productCategoryProperty;
	}
	
	/** must[产品属性项] */
	public bairui.international.model.domain.jpa.TB_ProductPropertyItem mustProductPropertyItem() {
		return this.productPropertyItem;
	}
	
	/** must[创建者] */
	public bairui.international.model.domain.jpa.TB_Admin mustCreator() {
		return this.creator;
	}
	
	/** must[最后修改者] */
	public bairui.international.model.domain.jpa.TB_Admin mustLastModifier() {
		return this.lastModifier;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ProductCategoryPropertyItem other = (TB_ProductCategoryPropertyItem) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((bairui.international.model.domain.jpa.TB_Admin)user);
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((bairui.international.model.domain.jpa.TB_Admin)user);
	}



}
